using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Media;
namespace Microsoft.Expression.Drawing.Core
{
	internal static class PathSegmentHelper
	{
		private static class ArcToBezierHelper
		{
			public static void ArcToBezier(double xStart, double yStart, double xRadius, double yRadius, double rRotation, bool fLargeArc, bool fSweepUp, double xEnd, double yEnd, out Point[] pPt, out int cPieces)
			{
				double num = 1E-06;
				pPt = new Point[12];
				double num2 = num * num;
				bool flag = false;
				cPieces = -1;
				double num3 = 0.5 * (xEnd - xStart);
				double num4 = 0.5 * (yEnd - yStart);
				double num5 = num3 * num3 + num4 * num4;
				if (num5 < num2)
				{
					return;
				}
				if (PathSegmentHelper.ArcToBezierHelper.AcceptRadius(num5, num2, ref xRadius) && PathSegmentHelper.ArcToBezierHelper.AcceptRadius(num5, num2, ref yRadius))
				{
					double num6;
					double num7;
					if (Math.Abs(rRotation) < num)
					{
						num6 = 1.0;
						num7 = 0.0;
					}
					else
					{
						rRotation = -rRotation * 3.1415926535897931 / 180.0;
						num6 = Math.Cos(rRotation);
						num7 = Math.Sin(rRotation);
						double num8 = num3 * num6 - num4 * num7;
						num4 = num3 * num7 + num4 * num6;
						num3 = num8;
					}
					num3 /= xRadius;
					num4 /= yRadius;
					num5 = num3 * num3 + num4 * num4;
					double num11;
					double num10;
					if (num5 > 1.0)
					{
						double num9 = Math.Sqrt(num5);
						xRadius *= num9;
						yRadius *= num9;
						num10 = (num11 = 0.0);
						flag = true;
						num3 /= num9;
						num4 /= num9;
					}
					else
					{
						double num12 = Math.Sqrt((1.0 - num5) / num5);
						if (fLargeArc != fSweepUp)
						{
							num11 = -num12 * num4;
							num10 = num12 * num3;
						}
						else
						{
							num11 = num12 * num4;
							num10 = -num12 * num3;
						}
					}
					Point point = new Point(-num3 - num11, -num4 - num10);
					Point point2 = new Point(num3 - num11, num4 - num10);
					Matrix matrix = new Matrix(num6 * xRadius, -num7 * xRadius, num7 * yRadius, num6 * yRadius, 0.5 * (xEnd + xStart), 0.5 * (yEnd + yStart));
					if (!flag)
					{
						matrix.set_OffsetX(matrix.get_OffsetX() + (matrix.get_M11() * num11 + matrix.get_M21() * num10));
						matrix.set_OffsetY(matrix.get_OffsetY() + (matrix.get_M12() * num11 + matrix.get_M22() * num10));
					}
					double num13;
					double num14;
					PathSegmentHelper.ArcToBezierHelper.GetArcAngle(point, point2, fLargeArc, fSweepUp, out num13, out num14, out cPieces);
					double num15 = PathSegmentHelper.ArcToBezierHelper.GetBezierDistance(num13, 1.0);
					if (!fSweepUp)
					{
						num15 = -num15;
					}
					Point rhs = new Point(-num15 * point.get_Y(), num15 * point.get_X());
					int num16 = 0;
					pPt = new Point[cPieces * 3];
					Point point4;
					for (int i = 1; i < cPieces; i++)
					{
						Point point3 = new Point(point.get_X() * num13 - point.get_Y() * num14, point.get_X() * num14 + point.get_Y() * num13);
						point4 = new Point(-num15 * point3.get_Y(), num15 * point3.get_X());
						pPt[num16++] = matrix.Transform(point.Plus(rhs));
						pPt[num16++] = matrix.Transform(point3.Minus(point4));
						pPt[num16++] = matrix.Transform(point3);
						point = point3;
						rhs = point4;
					}
					point4 = new Point(-num15 * point2.get_Y(), num15 * point2.get_X());
					pPt[num16++] = matrix.Transform(point.Plus(rhs));
					pPt[num16++] = matrix.Transform(point2.Minus(point4));
					pPt[num16] = new Point(xEnd, yEnd);
					return;
				}
				cPieces = 0;
			}
			private static void GetArcAngle(Point ptStart, Point ptEnd, bool fLargeArc, bool fSweepUp, out double rCosArcAngle, out double rSinArcAngle, out int cPieces)
			{
				rCosArcAngle = GeometryHelper.Dot(ptStart, ptEnd);
				rSinArcAngle = GeometryHelper.Determinant(ptStart, ptEnd);
				if (rCosArcAngle >= 0.0)
				{
					if (!fLargeArc)
					{
						cPieces = 1;
						return;
					}
					cPieces = 4;
				}
				else
				{
					if (fLargeArc)
					{
						cPieces = 3;
					}
					else
					{
						cPieces = 2;
					}
				}
				double num = Math.Atan2(rSinArcAngle, rCosArcAngle);
				if (fSweepUp)
				{
					if (num < 0.0)
					{
						num += 6.2831853071795862;
					}
				}
				else
				{
					if (num > 0.0)
					{
						num -= 6.2831853071795862;
					}
				}
				num /= (double)cPieces;
				rCosArcAngle = Math.Cos(num);
				rSinArcAngle = Math.Sin(num);
			}
			private static double GetBezierDistance(double rDot, double rRadius = 1.0)
			{
				double num = rRadius * rRadius;
				double result = 0.0;
				double num2 = 0.5 * (num + rDot);
				if (num2 >= 0.0)
				{
					double num3 = num - num2;
					if (num3 > 0.0)
					{
						double num4 = Math.Sqrt(num3);
						double num5 = 4.0 * (rRadius - Math.Sqrt(num2)) / 3.0;
						if (num5 <= num4 * 1E-06)
						{
							result = 0.0;
						}
						else
						{
							result = num5 / num4;
						}
					}
				}
				return result;
			}
			private static bool AcceptRadius(double rHalfChord2, double rFuzz2, ref double rRadius)
			{
				bool result;
				if ((result = (rRadius * rRadius > rHalfChord2 * rFuzz2)) && rRadius < 0.0)
				{
					rRadius = -rRadius;
				}
				return result;
			}
		}
		private abstract class PathSegmentImplementation
		{
			public Point Start
			{
				get;
				private set;
			}
			public abstract void Flatten(IList<Point> points, double tolerance);
			public abstract Point GetPoint(int index);
			public abstract IEnumerable<SimpleSegment> GetSimpleSegments();
			public static PathSegmentHelper.PathSegmentImplementation Create(PathSegment segment, Point start)
			{
				PathSegmentHelper.PathSegmentImplementation pathSegmentImplementation = PathSegmentHelper.PathSegmentImplementation.Create(segment);
				pathSegmentImplementation.Start = start;
				return pathSegmentImplementation;
			}
			public static PathSegmentHelper.PathSegmentImplementation Create(PathSegment segment)
			{
				PathSegmentHelper.PathSegmentImplementation result;
				if ((result = PathSegmentHelper.BezierSegmentImplementation.Create(segment as BezierSegment)) == null && (result = PathSegmentHelper.LineSegmentImplementation.Create(segment as LineSegment)) == null && (result = PathSegmentHelper.ArcSegmentImplementation.Create(segment as ArcSegment)) == null && (result = PathSegmentHelper.PolyLineSegmentImplementation.Create(segment as PolyLineSegment)) == null && (result = PathSegmentHelper.PolyBezierSegmentImplementation.Create(segment as PolyBezierSegment)) == null && (result = PathSegmentHelper.QuadraticBezierSegmentImplementation.Create(segment as QuadraticBezierSegment)) == null && (result = PathSegmentHelper.PolyQuadraticBezierSegmentImplementation.Create(segment as PolyQuadraticBezierSegment)) == null)
				{
					throw new NotImplementedException();
				}
				return result;
			}
		}
		private class BezierSegmentImplementation : PathSegmentHelper.PathSegmentImplementation
		{
			private BezierSegment segment;
			public static PathSegmentHelper.PathSegmentImplementation Create(BezierSegment source)
			{
				if (source != null)
				{
					return new PathSegmentHelper.BezierSegmentImplementation
					{
						segment = source
					};
				}
				return null;
			}
			public override void Flatten(IList<Point> points, double tolerance)
			{
				Point[] controlPoints = new Point[]
				{
					base.Start,
					this.segment.get_Point1(),
					this.segment.get_Point2(),
					this.segment.get_Point3()
				};
				List<Point> list = new List<Point>();
				BezierCurveFlattener.FlattenCubic(controlPoints, tolerance, list, true, null);
				points.AddRange(list);
			}
			public override Point GetPoint(int index)
			{
				if (index < -1 || index > 2)
				{
					throw new ArgumentOutOfRangeException("index");
				}
				if (index == 0)
				{
					return this.segment.get_Point1();
				}
				if (index == 1)
				{
					return this.segment.get_Point2();
				}
				return this.segment.get_Point3();
			}
			public override IEnumerable<SimpleSegment> GetSimpleSegments()
			{
				yield return SimpleSegment.Create(base.Start, this.segment.get_Point1(), this.segment.get_Point2(), this.segment.get_Point3());
				yield break;
			}
		}
		private class QuadraticBezierSegmentImplementation : PathSegmentHelper.PathSegmentImplementation
		{
			private QuadraticBezierSegment segment;
			public static PathSegmentHelper.PathSegmentImplementation Create(QuadraticBezierSegment source)
			{
				if (source != null)
				{
					return new PathSegmentHelper.QuadraticBezierSegmentImplementation
					{
						segment = source
					};
				}
				return null;
			}
			public override void Flatten(IList<Point> points, double tolerance)
			{
				Point[] controlPoints = new Point[]
				{
					base.Start,
					this.segment.get_Point1(),
					this.segment.get_Point2()
				};
				List<Point> list = new List<Point>();
				BezierCurveFlattener.FlattenQuadratic(controlPoints, tolerance, list, true, null);
				points.AddRange(list);
			}
			public override Point GetPoint(int index)
			{
				if (index < -1 || index > 1)
				{
					throw new ArgumentOutOfRangeException("index");
				}
				if (index == 0)
				{
					return this.segment.get_Point1();
				}
				return this.segment.get_Point2();
			}
			public override IEnumerable<SimpleSegment> GetSimpleSegments()
			{
				yield return SimpleSegment.Create(base.Start, this.segment.get_Point1(), this.segment.get_Point2());
				yield break;
			}
		}
		private class PolyBezierSegmentImplementation : PathSegmentHelper.PathSegmentImplementation
		{
			private PolyBezierSegment segment;
			public static PathSegmentHelper.PathSegmentImplementation Create(PolyBezierSegment source)
			{
				if (source != null)
				{
					return new PathSegmentHelper.PolyBezierSegmentImplementation
					{
						segment = source
					};
				}
				return null;
			}
			public override void Flatten(IList<Point> points, double tolerance)
			{
				Point point = base.Start;
				int num = this.segment.get_Points().get_Count() / 3 * 3;
				for (int i = 0; i < num; i += 3)
				{
					Point[] controlPoints = new Point[]
					{
						point,
						this.segment.get_Points().get_Item(i),
						this.segment.get_Points().get_Item(i + 1),
						this.segment.get_Points().get_Item(i + 2)
					};
					List<Point> list = new List<Point>();
					BezierCurveFlattener.FlattenCubic(controlPoints, tolerance, list, true, null);
					points.AddRange(list);
					point = this.segment.get_Points().get_Item(i + 2);
				}
			}
			public override Point GetPoint(int index)
			{
				int num = this.segment.get_Points().get_Count() / 3 * 3;
				if (index < -1 || index > num - 1)
				{
					throw new ArgumentOutOfRangeException("index");
				}
				if (index != -1)
				{
					return this.segment.get_Points().get_Item(index);
				}
				return this.segment.get_Points().get_Item(num - 1);
			}
			public override IEnumerable<SimpleSegment> GetSimpleSegments()
			{
				PathSegmentHelper.PolyBezierSegmentImplementation.<GetSimpleSegments>d__10 <GetSimpleSegments>d__ = new PathSegmentHelper.PolyBezierSegmentImplementation.<GetSimpleSegments>d__10(-2);
				<GetSimpleSegments>d__.<>4__this = this;
				return <GetSimpleSegments>d__;
			}
		}
		private class PolyQuadraticBezierSegmentImplementation : PathSegmentHelper.PathSegmentImplementation
		{
			private PolyQuadraticBezierSegment segment;
			public static PathSegmentHelper.PathSegmentImplementation Create(PolyQuadraticBezierSegment source)
			{
				if (source != null)
				{
					return new PathSegmentHelper.PolyQuadraticBezierSegmentImplementation
					{
						segment = source
					};
				}
				return null;
			}
			public override void Flatten(IList<Point> points, double tolerance)
			{
				Point point = base.Start;
				int num = this.segment.get_Points().get_Count() / 2 * 2;
				for (int i = 0; i < num; i += 2)
				{
					Point[] controlPoints = new Point[]
					{
						point,
						this.segment.get_Points().get_Item(i),
						this.segment.get_Points().get_Item(i + 1)
					};
					List<Point> list = new List<Point>();
					BezierCurveFlattener.FlattenQuadratic(controlPoints, tolerance, list, true, null);
					points.AddRange(list);
					point = this.segment.get_Points().get_Item(i + 1);
				}
			}
			public override Point GetPoint(int index)
			{
				int num = this.segment.get_Points().get_Count() / 2 * 2;
				if (index < -1 || index > num - 1)
				{
					throw new ArgumentOutOfRangeException("index");
				}
				if (index != -1)
				{
					return this.segment.get_Points().get_Item(index);
				}
				return this.segment.get_Points().get_Item(num - 1);
			}
			public override IEnumerable<SimpleSegment> GetSimpleSegments()
			{
				PathSegmentHelper.PolyQuadraticBezierSegmentImplementation.<GetSimpleSegments>d__19 <GetSimpleSegments>d__ = new PathSegmentHelper.PolyQuadraticBezierSegmentImplementation.<GetSimpleSegments>d__19(-2);
				<GetSimpleSegments>d__.<>4__this = this;
				return <GetSimpleSegments>d__;
			}
		}
		private class ArcSegmentImplementation : PathSegmentHelper.PathSegmentImplementation
		{
			private ArcSegment segment;
			public static PathSegmentHelper.PathSegmentImplementation Create(ArcSegment source)
			{
				if (source != null)
				{
					return new PathSegmentHelper.ArcSegmentImplementation
					{
						segment = source
					};
				}
				return null;
			}
			public override void Flatten(IList<Point> points, double tolerance)
			{
				PathSegment pathSegment = PathSegmentHelper.ArcToBezierSegments(this.segment, base.Start);
				if (pathSegment != null)
				{
					pathSegment.FlattenSegment(points, base.Start, tolerance);
				}
			}
			public override Point GetPoint(int index)
			{
				if (index < -1 || index > 0)
				{
					throw new ArgumentOutOfRangeException("index");
				}
				return this.segment.get_Point();
			}
			public override IEnumerable<SimpleSegment> GetSimpleSegments()
			{
				PathSegment pathSegment = PathSegmentHelper.ArcToBezierSegments(this.segment, base.Start);
				if (pathSegment != null)
				{
					return pathSegment.GetSimpleSegments(base.Start);
				}
				return Enumerable.Empty<SimpleSegment>();
			}
		}
		private class LineSegmentImplementation : PathSegmentHelper.PathSegmentImplementation
		{
			private LineSegment segment;
			public static PathSegmentHelper.PathSegmentImplementation Create(LineSegment source)
			{
				if (source != null)
				{
					return new PathSegmentHelper.LineSegmentImplementation
					{
						segment = source
					};
				}
				return null;
			}
			public override void Flatten(IList<Point> points, double tolerance)
			{
				points.Add(this.segment.get_Point());
			}
			public override Point GetPoint(int index)
			{
				if (index < -1 || index > 0)
				{
					throw new ArgumentOutOfRangeException("index");
				}
				return this.segment.get_Point();
			}
			public override IEnumerable<SimpleSegment> GetSimpleSegments()
			{
				yield return SimpleSegment.Create(base.Start, this.segment.get_Point());
				yield break;
			}
		}
		private class PolyLineSegmentImplementation : PathSegmentHelper.PathSegmentImplementation
		{
			private PolyLineSegment segment;
			public static PathSegmentHelper.PathSegmentImplementation Create(PolyLineSegment source)
			{
				if (source != null)
				{
					return new PathSegmentHelper.PolyLineSegmentImplementation
					{
						segment = source
					};
				}
				return null;
			}
			public override void Flatten(IList<Point> points, double tolerance)
			{
				points.AddRange(this.segment.get_Points());
			}
			public override Point GetPoint(int index)
			{
				if (index < -1 || index > this.segment.get_Points().get_Count() - 1)
				{
					throw new ArgumentOutOfRangeException("index");
				}
				if (index != -1)
				{
					return this.segment.get_Points().get_Item(index);
				}
				return this.segment.get_Points().Last<Point>();
			}
			public override IEnumerable<SimpleSegment> GetSimpleSegments()
			{
				PathSegmentHelper.PolyLineSegmentImplementation.<GetSimpleSegments>d__27 <GetSimpleSegments>d__ = new PathSegmentHelper.PolyLineSegmentImplementation.<GetSimpleSegments>d__27(-2);
				<GetSimpleSegments>d__.<>4__this = this;
				return <GetSimpleSegments>d__;
			}
		}
		public static PathSegment ArcToBezierSegments(ArcSegment arcSegment, Point startPoint)
		{
			bool isStroked = arcSegment.IsStroked();
			Point[] array;
			int num;
			PathSegmentHelper.ArcToBezierHelper.ArcToBezier(startPoint.get_X(), startPoint.get_Y(), arcSegment.get_Size().get_Width(), arcSegment.get_Size().get_Height(), arcSegment.get_RotationAngle(), arcSegment.get_IsLargeArc(), arcSegment.get_SweepDirection() == 1, arcSegment.get_Point().get_X(), arcSegment.get_Point().get_Y(), out array, out num);
			if (num == -1)
			{
				return null;
			}
			if (num == 0)
			{
				return PathSegmentHelper.CreateLineSegment(arcSegment.get_Point(), isStroked);
			}
			if (num == 1)
			{
				return PathSegmentHelper.CreateBezierSegment(array[0], array[1], array[2], isStroked);
			}
			return PathSegmentHelper.CreatePolyBezierSegment(array, 0, num * 3, isStroked);
		}
		private static void SetIsStroked(this PathSegment segment, bool isStroked)
		{
		}
		public static LineSegment CreateLineSegment(Point point, bool isStroked = true)
		{
			LineSegment lineSegment = new LineSegment();
			lineSegment.set_Point(point);
			lineSegment.SetIsStroked(isStroked);
			return lineSegment;
		}
		public static QuadraticBezierSegment CreateQuadraticBezierSegment(Point point1, Point point2, bool isStroked = true)
		{
			QuadraticBezierSegment quadraticBezierSegment = new QuadraticBezierSegment();
			quadraticBezierSegment.set_Point1(point1);
			quadraticBezierSegment.set_Point2(point2);
			quadraticBezierSegment.SetIsStroked(isStroked);
			return quadraticBezierSegment;
		}
		public static BezierSegment CreateBezierSegment(Point point1, Point point2, Point point3, bool isStroked = true)
		{
			BezierSegment bezierSegment = new BezierSegment();
			bezierSegment.set_Point1(point1);
			bezierSegment.set_Point2(point2);
			bezierSegment.set_Point3(point3);
			bezierSegment.SetIsStroked(isStroked);
			return bezierSegment;
		}
		public static PolyBezierSegment CreatePolyBezierSegment(IList<Point> points, int start, int count, bool isStroked = true)
		{
			if (points == null)
			{
				throw new ArgumentNullException("points");
			}
			count = count / 3 * 3;
			if (count >= 0 && points.get_Count() >= start + count)
			{
				PolyBezierSegment polyBezierSegment = new PolyBezierSegment();
				polyBezierSegment.set_Points(new PointCollection());
				for (int i = 0; i < count; i++)
				{
					polyBezierSegment.get_Points().Add(points.get_Item(start + i));
				}
				polyBezierSegment.SetIsStroked(isStroked);
				return polyBezierSegment;
			}
			throw new ArgumentOutOfRangeException("count");
		}
		public static PolyQuadraticBezierSegment CreatePolyQuadraticBezierSegment(IList<Point> points, int start, int count, bool isStroked = true)
		{
			if (points == null)
			{
				throw new ArgumentNullException("points");
			}
			count = count / 2 * 2;
			if (count >= 0 && points.get_Count() >= start + count)
			{
				PolyQuadraticBezierSegment polyQuadraticBezierSegment = new PolyQuadraticBezierSegment();
				polyQuadraticBezierSegment.set_Points(new PointCollection());
				for (int i = 0; i < count; i++)
				{
					polyQuadraticBezierSegment.get_Points().Add(points.get_Item(start + i));
				}
				polyQuadraticBezierSegment.SetIsStroked(isStroked);
				return polyQuadraticBezierSegment;
			}
			throw new ArgumentOutOfRangeException("count");
		}
		public static PolyLineSegment CreatePolylineSegment(IList<Point> points, int start, int count, bool isStroked = true)
		{
			if (count >= 0 && points.get_Count() >= start + count)
			{
				PolyLineSegment polyLineSegment = new PolyLineSegment();
				polyLineSegment.set_Points(new PointCollection());
				for (int i = 0; i < count; i++)
				{
					polyLineSegment.get_Points().Add(points.get_Item(start + i));
				}
				polyLineSegment.SetIsStroked(isStroked);
				return polyLineSegment;
			}
			throw new ArgumentOutOfRangeException("count");
		}
		public static ArcSegment CreateArcSegment(Point point, Size size, bool isLargeArc, bool clockwise, double rotationAngle = 0.0, bool isStroked = true)
		{
			ArcSegment arcSegment = new ArcSegment();
			arcSegment.SetIfDifferent(ArcSegment.PointProperty, point);
			arcSegment.SetIfDifferent(ArcSegment.SizeProperty, size);
			arcSegment.SetIfDifferent(ArcSegment.IsLargeArcProperty, isLargeArc);
			arcSegment.SetIfDifferent(ArcSegment.SweepDirectionProperty, clockwise ? 1 : 0);
			arcSegment.SetIfDifferent(ArcSegment.RotationAngleProperty, rotationAngle);
			arcSegment.SetIsStroked(isStroked);
			return arcSegment;
		}
		public static bool SyncPolylineSegment(PathSegmentCollection collection, int index, IList<Point> points, int start, int count)
		{
			if (collection == null)
			{
				throw new ArgumentNullException("collection");
			}
			if (index < 0 || index >= collection.get_Count())
			{
				throw new ArgumentOutOfRangeException("index");
			}
			if (points == null)
			{
				throw new ArgumentNullException("points");
			}
			if (start < 0)
			{
				throw new ArgumentOutOfRangeException("start");
			}
			if (count < 0)
			{
				throw new ArgumentOutOfRangeException("count");
			}
			if (points.get_Count() < start + count)
			{
				throw new ArgumentOutOfRangeException("count");
			}
			bool flag = false;
			PolyLineSegment polyLineSegment;
			if ((polyLineSegment = (collection.get_Item(index) as PolyLineSegment)) == null)
			{
				collection.set_Item(index, polyLineSegment = new PolyLineSegment());
				flag = true;
			}
			flag |= polyLineSegment.get_Points().EnsureListCount(count, null);
			for (int i = 0; i < count; i++)
			{
				if (polyLineSegment.get_Points().get_Item(i) != points.get_Item(i + start))
				{
					polyLineSegment.get_Points().set_Item(i, points.get_Item(i + start));
					flag = true;
				}
			}
			return flag;
		}
		public static bool SyncPolyBezierSegment(PathSegmentCollection collection, int index, IList<Point> points, int start, int count)
		{
			if (collection == null)
			{
				throw new ArgumentNullException("collection");
			}
			if (index < 0 || index >= collection.get_Count())
			{
				throw new ArgumentOutOfRangeException("index");
			}
			if (points == null)
			{
				throw new ArgumentNullException("points");
			}
			if (start < 0)
			{
				throw new ArgumentOutOfRangeException("start");
			}
			if (count < 0)
			{
				throw new ArgumentOutOfRangeException("count");
			}
			if (points.get_Count() < start + count)
			{
				throw new ArgumentOutOfRangeException("count");
			}
			bool result = false;
			count = count / 3 * 3;
			PolyBezierSegment polyBezierSegment;
			if ((polyBezierSegment = (collection.get_Item(index) as PolyBezierSegment)) == null)
			{
				collection.set_Item(index, polyBezierSegment = new PolyBezierSegment());
				result = true;
			}
			polyBezierSegment.get_Points().EnsureListCount(count, null);
			for (int i = 0; i < count; i++)
			{
				if (polyBezierSegment.get_Points().get_Item(i) != points.get_Item(i + start))
				{
					polyBezierSegment.get_Points().set_Item(i, points.get_Item(i + start));
					result = true;
				}
			}
			return result;
		}
		public static bool IsEmpty(this PathSegment segment)
		{
			return segment.GetPointCount() == 0;
		}
		public static int GetPointCount(this PathSegment segment)
		{
			if (segment is ArcSegment)
			{
				return 1;
			}
			if (segment is LineSegment)
			{
				return 1;
			}
			if (segment is QuadraticBezierSegment)
			{
				return 2;
			}
			if (segment is BezierSegment)
			{
				return 3;
			}
			PolyLineSegment polyLineSegment;
			if ((polyLineSegment = (segment as PolyLineSegment)) != null)
			{
				return polyLineSegment.get_Points().get_Count();
			}
			PolyQuadraticBezierSegment polyQuadraticBezierSegment;
			if ((polyQuadraticBezierSegment = (segment as PolyQuadraticBezierSegment)) != null)
			{
				return polyQuadraticBezierSegment.get_Points().get_Count() / 2 * 2;
			}
			PolyBezierSegment polyBezierSegment;
			if ((polyBezierSegment = (segment as PolyBezierSegment)) != null)
			{
				return polyBezierSegment.get_Points().get_Count() / 3 * 3;
			}
			return 0;
		}
		public static Point GetLastPoint(this PathSegment segment)
		{
			return segment.GetPoint(-1);
		}
		public static Point GetPoint(this PathSegment segment, int index)
		{
			return PathSegmentHelper.PathSegmentImplementation.Create(segment).GetPoint(index);
		}
		public static void FlattenSegment(this PathSegment segment, IList<Point> points, Point start, double tolerance)
		{
			PathSegmentHelper.PathSegmentImplementation.Create(segment, start).Flatten(points, tolerance);
		}
		public static IEnumerable<SimpleSegment> GetSimpleSegments(this PathSegment segment, Point start)
		{
			PathSegmentHelper.<GetSimpleSegments>d__0 <GetSimpleSegments>d__ = new PathSegmentHelper.<GetSimpleSegments>d__0(-2);
			<GetSimpleSegments>d__.<>3__segment = segment;
			<GetSimpleSegments>d__.<>3__start = start;
			return <GetSimpleSegments>d__;
		}
	}
}
